/**
 * COPYRIGHT HangZhou Trustway Technology Company Limited
 * All right reserved.
 */
package com.robam.apollotest.apollotest.controller;

import com.robam.apollotest.apollotest.common.Test;
import com.robam.apollotest.apollotest.helper.ApolloTestHelper;
import com.robam.cloud.common.bean.restful.entity.RespMsg;
import com.robam.cloud.log.annotation.OperationLogRecord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Description
 * @Author 薛铁琪
 * @CreateTime 2020-09-25 16:34
 * @Version 1.0
 */
@Api("mqtest-productor")
@RestController
@RequestMapping("/test")
@Slf4j
public class ApolloTestController {
    @Autowired
    HttpServletRequest httpServletRequest;
    @Autowired
    ApolloTestHelper apolloTestHelper;
    @Autowired
    Test test;
    @Resource
    private ApplicationContext ctx;

    @ApiOperation(
            value = "test",
            notes = "test")
    @OperationLogRecord(
            describe = "test",
            modularCode = "/test",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    @RequestMapping(
            value = "/test",
            method = RequestMethod.GET)
    public RespMsg test() {
        log.debug("debug");
        log.info("info");
        log.warn("warn");
        log.error("error");
        String[] activeProfiles = ctx.getEnvironment().getActiveProfiles();
        return RespMsg.success(StringUtils.arrayToCommaDelimitedString(activeProfiles)+apolloTestHelper.test() + test);
    }

}
